Component({
    properties: {},
    data: {
        imageUrl: '',
        imageUrl2: ''
    },
    methods: {
        uploadFile() {
            const that = this
            wx.chooseMedia({
                count: 1,
                mediaType: ['image','video'],
                // 	album：从相册选择；camera：使用相机拍摄
                sourceType: ['album', 'camera'],
                maxDuration: 30,
                camera: 'back',
                success(res) {
                   /* console.log(res.tempFiles.tempFilePath)
                    console.log(res.tempFiles.size)*/
                    console.log(res)
                    const tempFilePath = res.tempFiles[0]['tempFilePath']
                    that.setData({
                        imageUrl: tempFilePath
                    })
                },
                error(res) {
                    console.log(res)
                }
            })
        },
        uploadFile2() {
            const that = this
            wx.chooseImage({
                success (res) {

                    const tempFilePath = res.tempFilePaths[0]
                    that.setData({
                        imageUrl2: tempFilePath
                    })

                    wx.uploadFile({
                        url: 'http://sb.test:8080/upload.php', //仅为示例，非真实的接口地址
                        filePath: tempFilePath,
                        name: 'file',
                        success (res){
                            // const data = res.data
                            //do something
                            console.log(res)
                        },
                        fail(res) {
                            console.log(res)
                        }
                    })
                }
            })
        }
    }
});
